import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JCheckBox;

public class popclickmenu extends MouseAdapter { /*Popclickmenu est l'ecouteur pour afficher le menu lors d'un clic droit*/
	static popupmenu menu = new popupmenu();
    public void mousePressed(MouseEvent e){
        if (e.isPopupTrigger())
            doPop(e);
    }

    public void mouseReleased(MouseEvent e){
        if (e.isPopupTrigger())
            doPop(e);
    }

    private void doPop(MouseEvent e){  
        menu.show(e.getComponent(), e.getX(), e.getY());
        popupmenu.menuEnvoyer.removeAll();
        popupmenu.itemsIPs.clear();
        popupmenu.menuEnvoyer.add(popupmenu.rafraichir);
        for(int i = 0; i < testIP.adresses.size(); i++){
        	if (popupmenu.selectedIPs.contains(testIP.adresses.get(i).toString()));
        	popupmenu.itemsIPs.add(new JCheckBox(testIP.adresses.get(i).toString()));
        	popupmenu.itemsIPs.get(i).setFont(popupmenu.thefont);
        	if (popupmenu.selectedIPs.contains(testIP.adresses.get(i).toString()))
    			popupmenu.itemsIPs.get(i).setSelected(true);
        	popupmenu.itemsIPs.get(i).addItemListener(new listlistener());
        	popupmenu.menuEnvoyer.add(popupmenu.itemsIPs.get(i));
        	
        	
        	
			char[] pass = popupmenu.motdepasse.getPassword();	
			String password = new String(pass);
			
			
			if(!(password.equals(cmd.mot_de_passe_univ )))
			{				
				popupmenu.mdp_correct = 0;
			}
			else{
				popupmenu.mdp_correct = 1;
			}
        }
    }
}
